<template>
	<view>
		<view class="form_bottom_btn" :key="count">
			<view class="btn-box">
				<view v-for="(item, index) in dataConfig" :key="index" :class="item.class" @click="clickBtnItem(item)">
					{{ item.text }}
				</view>
			</view>
		</view>
	</view>
</template>
<script setup>
	import {
		ref,
		reactive,
		defineProps,
		watch,
		defineEmits
	} from 'vue'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	let dataConfig = reactive([])
	let count = ref(false)
	let {
		btnConfig
	} = defineProps({
		btnConfig: {
			type: Array,
			default: []
		}
	})
	watch(btnConfig, (newVal, oldVal) => {
		// dataConfig.splice(0, dataConfig.length, uni.$u.deepClone(newVal))
		dataConfig = uni.$u.deepClone(newVal)
		count.value = !count.value
	}, {
		immediate: true,
		deep: true
	})

	onLoad(() => {
		// dataConfig.splice(0, dataConfig.length, uni.$u.deepClone(btnConfig))
		dataConfig = uni.$u.deepClone(btnConfig)
		console.log(dataConfig);
	})

	function clickBtnItem(item) {
		const emit = defineEmits([item.funcName])
		emit(item.funcName)
	}
</script>

<style scoped lang="less">
	.form_bottom_btn {
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		padding: 0 22rpx;
		padding-bottom: env(safe-area-inset-bottom);
		background-color: #fff;
		z-index: 2;

		.btn-box {
			width: 100%;
			height: 64px;
			display: flex;
			justify-content: space-around;
			align-items: center;
			flex-wrap: nowrap;

			.cancel {
				flex: 1;
				// width: 100%;
				height: 90rpx;
				margin: 8rpx;
				border-radius: 20rpx;
				text-align: center;
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 500;
				line-height: 90rpx;
				color: #325ef5;
				background: #FFFFFF;
				border: 2rpx solid #325ef5;
				white-space: nowrap;
			}

			.confirm {
				flex: 1;
				// width: 100%;
				height: 90rpx;
				margin: 8rpx;
				border-radius: 20rpx;
				text-align: center;
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 500;
				line-height: 90rpx;
				color: #FFFFFF;
				background: #325ef5;
			}

			.exhibition {
				flex: 1;
				// width: 100%;
				height: 90rpx;
				margin: 8rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				line-height: 90rpx;
				color: #325ef5;
				background: #FFFFFF;
			}
		}
	}
</style>